package com.jiutong.meipenggang.http.model.requests;


import com.jiutong.meipenggang.http.RetrofitHandle;
import com.jiutong.meipenggang.http.SubscribeHandler;
import com.jiutong.meipenggang.http.model.services.UserInfoService;
import com.jiutong.meipenggang.http.subscribers.ProgressSubscriber;


import java.util.HashMap;
import java.util.Map;

import rx.Observable;
import rx.Subscriber;


/**
 * Created by Veken on 2017/5/27.
 */

public class UserInfoRequest extends SubscribeHandler {

    /**
     * 注册接口
     */
    public void registed(Subscriber subscriber, Map<String, Object> fields) {

        handleFields(fields);
        Observable observable = RetrofitHandle.getInstance().retrofit.create(UserInfoService.class)
                .register(fields);

        toSubscribe(observable, subscriber);
    }

    /**
     * 登录
     *
     * @param subscriber
     * @param fields
     */
    public void login(Subscriber subscriber, Map<String, Object> fields) {
        handleFields(fields);
        Observable observable = RetrofitHandle.getInstance().retrofit.create(UserInfoService.class)
                .login(fields);
        toSubscribe(observable, subscriber);
    }


    /**
     * 获取验证码
     *
     * @param subscriber
     * @param fields
     */
    public void getAuthCode(ProgressSubscriber subscriber, HashMap<String, Object> fields) {
        handleFields(fields);
        Observable observable = RetrofitHandle.getInstance().retrofit.create(UserInfoService.class)
                .getAuthCode(fields);
        toSubscribe(observable, subscriber);
    }



    /**
     * 忘记密码
     *
     * @param subscriber
     * @param fields
     */
    public void forgetPwd(ProgressSubscriber subscriber, HashMap<String, Object> fields) {
        handleFields(fields);
        Observable observable = RetrofitHandle.getInstance().retrofit.create(UserInfoService.class)
                .forgetPwd(fields);
        toSubscribe(observable, subscriber);
    }

    /**
     * 密码重置（手机验证码）
     *
     * @param subscriber
     * @param fields
     */
    public void pwdResetByCode(ProgressSubscriber subscriber, HashMap<String, Object> fields) {
        handleFields(fields);
        Observable observable = RetrofitHandle.getInstance().retrofit.create(UserInfoService.class)
                .pwdResetByCode(fields);
        toSubscribe(observable, subscriber);
    }

//    /**
//     * 关于我们
//     *
//     * @param subscriber
//     * @param fields
//     */
//    public void aboutUs(ProgressSubscriber subscriber, HashMap<String, Object> fields) {
//        fields.put("method", "article.getList");
//        handleFields(fields);
//        Observable observable = HttpRequest.getInstance().retrofit.create(UserInfoService.class)
//                .aboutUs(fields);
//        toSubscribe(observable, subscriber);
//    }



//    /**
//     * 发送极光registrationId
//     *
//     * @param subscriber
//     * @param fieldMap
//     */
//    public void sentId(ProgressSubscriber subscriber, HashMap fieldMap) {
//        fieldMap.put("method", "registrationid.add");
//        handleFields(fieldMap);
//        Observable observable = HttpRequest.getInstance().retrofit.create(UserInfoService.class)
//                .sentId(fieldMap);
//        toSubscribe(observable, subscriber);
//    }

    /**
     * 服务协议
     *
     * @param subscriber
     * @param fields
     */
    public void serviceAgreement(ProgressSubscriber subscriber, HashMap<String, Object> fields) {
        handleFields(fields);
        Observable observable = RetrofitHandle.getInstance().retrofit.create(UserInfoService.class)
                .serviceAgreement(fields);
        toSubscribe(observable, subscriber);
    }

    /**
     * 服务协议
     *
     * @param subscriber
     * @param fields
     */
    public void getCityList(ProgressSubscriber subscriber, HashMap<String, Object> fields) {
        handleFields(fields);
        Observable observable = RetrofitHandle.getInstance().retrofit.create(UserInfoService.class)
                .getCityList(fields);
        toSubscribe(observable, subscriber);
    }

    /**
     * 手势密码登录
     *
     * @param subscriber
     * @param fields
     */
    public void gestureLogin(ProgressSubscriber subscriber, HashMap<String, Object> fields) {
        handleFields(fields);
        Observable observable = RetrofitHandle.getInstance().retrofit.create(UserInfoService.class)
                .gestureLogin(fields);
        toSubscribe(observable, subscriber);
    }

    /**
     * 修改手势密码
     *
     * @param subscriber
     * @param fields
     */
    public void gestureChange(ProgressSubscriber subscriber, HashMap<String, Object> fields) {
        handleFields(fields);
        Observable observable = RetrofitHandle.getInstance().retrofit.create(UserInfoService.class)
                .gestureChange(fields);
        toSubscribe(observable, subscriber);
    }




}
